from pattern.circuit import Control


class entry(Control):
    
    def incoming(self, event):
        root, = event.data
        bridge = self.acquireInterface(event, "out")
        if bridge is not None:
            bridge.push(self.walk(root))

    def walk(self, root):
        return "(" + "\n".join([root.value()] + [self.walk(node) for node in root.childNodes()]) + ")"